<template>
  <div class="Baybox">
    <div class="title">
      <div class="left">
        <div class="length"></div>
        <div class="text">回路监测--{{ treevalue.name }}</div>
      </div>
      <div>
        <span class="time">数据时间：</span>
        <el-date-picker
          v-model="date"
          type="date"
          size="small"
          value-format="yyyy-MM-dd"
          @change="getallmethod(treevalue)"
          placeholder="选择日期">
        </el-date-picker>
      </div>
    </div>
    <div class="realtime">
      <div class="realbox parang">
        <div class="left">
          <div class="text">当前实时负荷(kW)</div>
          <div class="number">{{ entityvalue.currentRealLoad }}</div>
        </div>
        <div class="right">
          <img src="@/assets/ElectricalDistribution/SX-hrss/image copy.png" alt="">
        </div>
      </div>
      <div class="realbox parang">
        <div class="left">
          <div class="text">昨日最大负荷(kW)</div>
          <div class="number">{{ entityvalue.yesterdayMaxLoad }}</div>
          <div class="text">{{ entityvalue.yesterdayMaxLoadTime }}</div>
        </div>
        <div class="right">
          <img src="@/assets/ElectricalDistribution/SX-hrss/image copy 2.png" alt="">
        </div>
      </div>
      <div class="realbox parang">
        <div class="left">
          <div class="text">昨日平均负荷(kW)</div>
          <div class="number">{{ entityvalue.yesterdayAvgLoad }}</div>
        </div>
        <div class="right">
          <img src="@/assets/ElectricalDistribution/SX-hrss/image copy 3.png" alt="">
        </div>
      </div>
      <div class="realbox">
        <div class="left">
          <div class="text">昨日最小负荷(kW)</div>
          <div class="number">{{ entityvalue.yesterdayMinLoad }}</div>
          <div class="text">{{ entityvalue.yesterdayMinLoadTime }}</div>
        </div>
        <div class="right">
          <img src="@/assets/ElectricalDistribution/SX-hrss/image copy 4.png" alt="">
        </div>
      </div>
    </div>
    <div class="echartbox">
      <div class="tit">
        <div class="left">
          <div class="length"></div>
          <div class="text">负荷</div>
        </div>
      </div>
      <div class="echart" ref="loadrefs"></div>
    </div>
    <div class="echartbox">
      <div class="tit">
        <div class="left">
          <div class="length"></div>
          <div class="text">电量</div>
        </div>
      </div>
      <div class="echart" ref="elerefs"></div>
    </div>
    <div class="twobox">
      <div class="littlebox leftbox">
        <div class="tit">
          <div class="left">
            <div class="length"></div>
            <div class="text">柔性负荷监测</div>
          </div>
        </div>
        <div class="echart" ref="rourefs"></div>
      </div>
      <div class="littlebox">
        <div class="tit">
          <div class="left">
            <div class="length"></div>
            <div class="text">刚性负荷监测</div>
          </div>
        </div>
        <div class="echart" ref="gangrefs"></div>
      </div>
    </div>
  </div>
</template>
<script>
import {Bayinfoapi,Bayrouapi,Baydianapi,Bayloadapi,Baygangapi} from '@/api/ElectricalDistribution/ResourceMonitoring'
import { GetdataZoomEchart } from '../components/dataZoomech'
import dayjs from 'dayjs';
export default {
  name: 'CallPoliceIndex',
  props: {
    treevalue: {
      type: Object,
      default:()=>{}
    }
  },
  data() {
    return {
      date: '',
      entityvalue: {},
      colorlist:['#61ddc8','#eec071']
    };
  },

  mounted() {
    
  },

  methods: {
    async getallmethod(val) {
      const { data: { entity } } = await Bayinfoapi({ devId: val.id, day: this.date })
      const {data:{list}}=await Bayrouapi({ devId: val.id, day: this.date })
      const {data:{list:elelist}}=await Baydianapi({ devId: val.id, day: this.date })
      const {data:{list:loadlist}}=await Bayloadapi({ devId: val.id, day: this.date })
      const {data:{list:ganglist}}=await Baygangapi({ devId: val.id, day: this.date })
      this.entityvalue = entity
      GetdataZoomEchart(this.$refs.rourefs,list,this.colorlist)
      GetdataZoomEchart(this.$refs.elerefs,elelist,this.colorlist,true)
      GetdataZoomEchart(this.$refs.loadrefs,loadlist,this.colorlist,true)
      GetdataZoomEchart(this.$refs.gangrefs,ganglist,this.colorlist)
    }
  },
  watch: {
    treevalue: {
      immediate:true,
      handler(newValue, oldValue) {
        this.date=dayjs().format('YYYY-MM-DD')
        this.getallmethod(newValue)
      },
      deep: true // 深度监听对象内部属性的变化
    }
  }
};
</script>
<style lang="scss" scoped>
.Baybox{
  .title{
    display:flex;
    justify-content:space-between;
    height:60px;
    align-items:center;
    background-color:#fff;
    padding:0 20px;
    .left{
      display:flex;
      font-weight: bold;
      .length{
        width:3px;
        height:20px;
        background-color:#3b8eea;
        margin-right:10px;
      }
    }
    .time{
      font-size:14px;
      color:#606266;
    }
  }
  .echartbox{
    height: 300px;
    padding: 20px;
    background-color: #fff;
    margin-top: 10px;
  }
  .real{
    margin-top: 10px;
  }
  .tit{
      display:flex;
      // margin-bottom: 10px;
      justify-content:space-between;
      .left{
        display:flex;
        font-weight: bold;
        .length{
          width:3px;
          height:20px;
          background-color:#3b8eea;
          margin-right:10px;
        }
      }
    }
    .echart{
      height: 90%;
    }
  .realtime{
    height: 130px;
    margin: 10px 0;
    display: flex;
    .realbox{
      width: calc(25% - 7.5px);
      background-color: #fff;
      padding: 20px;
      display: flex;
      .left{
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
        width: 55%;
        .text{
          font-size: 14px;
          color:#606266;
        }
        .number{
          font-size: 18px;
          color: #000;
        }
      }
      .right{
        width: 45%;
        display: flex;
        align-items: center;
      }
    }
    .parang{
      margin-right: 10px;
    }
  }
  .twobox{
    height: 300px;
    display: flex;
    margin-top: 10px;
    .littlebox{
      width: calc(50% - 5px);
      background-color: #fff;
      padding: 20px;
    }
    .leftbox{
      margin-right: 10px;
    }
  }
}
</style>